import 'dio_api.dart';

const host = "https://lizo.top"; // api地址
MyAppApiCommon myAppApiCommon = MyAppApiCommon();

class MyAppApiCommon extends MyDio {
  Future<String> getHostHealth() async => (await this.getQuery("$host/health")).toString(); // 测试一
  Future<String> getHostHealthPing() async => (await this.getQuery("$host/health/ping")).toString(); // 测试二

  // 登录
  Future<T> userLogin<T>(String phone, String password) async {
    return this.postForm("$host/api/user/login", formData: {"phone": phone, "password": password});
  }

  // 注册
  Future<T> userRegister<T>(String phone, String password, String validCode) async {
    return this.postForm("$host/api/user/register", formData: {"phone": phone, "password": password, "valid_code": validCode});
  }

  // 发注册短信
  Future<T> userSendSms<T>(String phone, String sendType) async {
    return this.postForm("$host/api/user/send_sms", formData: {"phone": phone, "send_type": sendType});
  }

  Future<T> userSendSmsRegister<T>(String phone) async => this.userSendSms(phone, "register"); // 注册发短信
  Future<T> userSendSmsLogin<T>(String phone) async => this.userSendSms(phone, "login"); // 登录发短信
  Future<T> userSendSmsChangePassword<T>(String phone) async => this.userSendSms(phone, "change_password"); // 改密发短信

}
